package com.bean;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Slf4j
@Data
public class LifeCycleBean {

    private Bean1 bean1;
    private Bean2 bean2;

    public LifeCycleBean() {
        log.info("构造");
    }

    @Autowired
    public void setBean2(Bean2 bean2) {
        log.info("@Autowired自动注入,{}",bean2);
        this.bean2 = bean2;
    }

    @Resource
    public void setBean1(Bean1 bean1){
        log.info("@Resource自动注入,{}",bean1);
        this.bean1=bean1;
    }

    @PostConstruct
    public void init(){
        log.info("自动注入完成之后的初始化");
    }

    @PreDestroy
    public void destroy(){
        log.info("销毁之前");
    }

}
